package com.aiit.controller;


import com.aiit.pojo.Company;
import com.aiit.service.CompanyService;
import com.aiit.util.TableResult;
import com.aiit.vo.PageResultVo;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: LuTao
 * @Date: 2022/05/06/10:40
 */
@Controller
public class CompanyController {
    @Autowired
    private CompanyService companyService;

    @ResponseBody
    @GetMapping("/company/getByCondition")
    public TableResult<Company> getByCondition(@RequestParam("page")Long page,
                                               @RequestParam("limit")Long limit,
                                               @RequestParam("name")String name,
                                               @RequestParam("startDate")String startDate,
                                               @RequestParam(value = "endDate",required = false) String endDate,
                                               @RequestParam("listedStatus")String listedStatus, @RequestParam("size") String size){
        PageResultVo<Company> pageResultVo = companyService.getByCondition(page,limit,name,listedStatus,size,startDate,endDate);
        return new TableResult(0,"",pageResultVo.getTotal(),pageResultVo.getRecords());
    }
}
